home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 16
/
AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso
/
pd
/
anwendungen
/
xpk_source
/
xpkmaster
/
objects.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-08-27
|
2KB
|
66 lines
#ifndef XPKMASTER_OBJECTS_C
#define XPKMASTER_OBJECTS_C
/* Routinesheader
Name: objects.c
Main: xpkmaster
Versionstring: $VER: objects.c 1.2 (21.02.1998)
Author: SDI
Distribution: Freeware
Description: object allocation functions and prefs sem get funcs
1.0 27.12.96 : first version
1.1 09.01.98 : added XPK_ALLINONE
1.2 21.02.98 : uses new style register definition
*/
#include <proto/exec.h>
#include <exec/memory.h>
#include <xpk/xpk.h>
#include <xpk/xpkprefs.h>
#include "xpkmaster.h"
XPK_ALLINONE struct XpkPrefsSemaphore *GetPrefsSem(void)
{
struct XpkPrefsSemaphore *sem;
Forbid();
if((sem = (struct XpkPrefsSemaphore *) FindSemaphore(XPKPREFSSEMNAME)))
ObtainSemaphoreShared((struct SignalSemaphore *) sem);
Permit();
return sem;
}
static ULONG GetXpkObjectSize(ULONG type)
{
switch(type)
{
case XPKOBJ_FIB: return sizeof(struct XpkFib); break;
case XPKOBJ_PACKERINFO: return sizeof(struct XpkPackerInfo); break;
case XPKOBJ_MODE: return sizeof(struct XpkMode); break;
case XPKOBJ_PACKERLIST: return sizeof(struct XpkPackerList); break;
};
return 0;
}
ASM(APTR) LIBXpkAllocObject(REG(d0, ULONG type), REG(a0, struct TagItem *tags))
{
ULONG size;
if((size = GetXpkObjectSize(type)))
return AllocMem(size, MEMF_PUBLIC|MEMF_CLEAR);
return 0;
}
ASM(void) LIBXpkFreeObject(REG(d0, ULONG type), REG(a0, APTR object))
{
ULONG size;
if((size = GetXpkObjectSize(type)))
FreeMem(object, size);
}
#endif /* XPKMASTER_OBJECTS_C */